package com.mz.ozy.mvp.presenter;


import android.app.Activity;

import com.mz.ozy.base.BasePresenterImpl;
import com.mz.ozy.bean.LockInfoBean;
import com.mz.ozy.mvp.model.PledgeModel;
import com.mz.ozy.mvp.view.PledgeContract;
import com.mz.ozy.net.MyObserver;
import com.mz.ozy.utils.RxUtil;

import org.json.JSONObject;

import okhttp3.ResponseBody;

/**
 * Created by administrator on 2018/12/3.
 */
public class PledgePresenter extends BasePresenterImpl<PledgeContract.View> implements PledgeContract.Presenter {

    private PledgeModel mModel;

    public PledgePresenter() {
        mModel = new PledgeModel();
    }

    @Override
    public void getStorageInfo(Activity activity) {
        mModel.getStorageInfo(activity)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<LockInfoBean>(mView) {
                    @Override
                    public void onSuccesss(LockInfoBean bean) {
                        mView.getStorageInfoSuccess(bean);
                    }
                });
    }

    @Override
    public void confirmStore(Activity activity, String amt, String password) {
        mModel.confirmStore(activity, amt, password)
                .compose(RxUtil.rxSchedulerHelper(mView.<ResponseBody>bindToLifecycle()))
                .subscribe(new MyObserver<JSONObject>(mView) {
                    @Override
                    public void onSuccesss(JSONObject bean) {
                        mView.confirmStoreSuccess(bean);
                    }
                });
    }
}
